package org.yzh.codec;

import io.github.yezhihao.protostar.FieldFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import org.yzh.protocol.JT808Beans;
import org.yzh.protocol.codec.JTMessageEncoder;
import org.yzh.protocol.t808.T0100;
import org.yzh.protocol.t808.T0200;

import java.time.LocalDateTime;

/**
 * 编码分析
 * @author yezhihao
 * @home https://gitee.com/yezhihao/jt808-server
 */
public class DarkRepulsor {

    private static JTMessageEncoder encoder;

    static {
        FieldFactory.EXPLAIN = true;
        encoder = new JTMessageEncoder("org.yzh.protocol");
    }

    public static void main(String[] args) {
//        T0100 message = JT808Beans.T0100();
//        JT808Beans.H2013(message);
//        ByteBuf byteBuf = encoder.encode(message);
//        System.out.println();
//        System.out.println(ByteBufUtil.hexDump(byteBuf));

//        System.out.println("T0200");
//        T0200 t0200 = JT808Beans.T0200();
//        JT808Beans.H2013(t0200);
//        System.out.println();
//        System.out.println(ByteBufUtil.hexDump(encoder.encode(t0200)));

//        System.out.println("T0200_FCW");
//        T0200 t0200Fcw = JT808Beans.T0200_FCW();
//        JT808Beans.H2013(t0200Fcw);
//        System.out.println();
//        System.out.println(ByteBufUtil.hexDump(encoder.encode(t0200Fcw)));

        System.out.println("T0200JSATL");
        T0200 jsatl12 = JT808Beans.T0200JSATL12();
        jsatl12.setDateTime(LocalDateTime.now());
        JT808Beans.H2013(jsatl12);
        System.out.println();
        System.out.println(ByteBufUtil.hexDump(encoder.encode(jsatl12)));

//        System.out.println("T0200SLI");
//        T0200 t0200Sli = JT808Beans.T0200_SLI();
//        JT808Beans.H2013(t0200Sli);
//        System.out.println();
//        System.out.println(ByteBufUtil.hexDump(encoder.encode(t0200Sli)));
    }
}